package com.base.power.demo.sys.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 类描述：菜单节点
 */
public class Tree implements Comparable<Tree>, Serializable {

    public Tree(){
        super();
    }

    public Tree(int id){
        this.id = id;
    }

    private static final long serialVersionUID = 4848569429687894769L;
    // 菜单流水ID
    private int id;
    // 菜单名字
    private String name;
    // 菜单编码
    private String code;
    // 菜单样式
    private String icon;
    // 菜单地址
    private String url;
    // 父节点ID
    private int pId;
    // 菜单排序
    private int treeOrder;
    // 菜单状态(1:正常；2：禁用)
    private String state;
    // 菜单类型(1:菜单节点；2：按钮节点)
    private String type;
    // 父菜单信息
    private Tree tree;
    // 菜单节点是否选中的状态
    private boolean checked;
    // 子菜单节点信息
    private List<Tree> child = new ArrayList<Tree>();

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public Tree getTree() {
        return tree;
    }

    public void setTree(Tree tree) {
        this.tree = tree;
    }

    public List<Tree> getChild() {
        return child;
    }

    public void setChild(List<Tree> child) {
        this.child = child;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getpId() {
        return pId;
    }

    public void setpId(int pId) {
        this.pId = pId;
    }

    public int getTreeOrder() {
        return treeOrder;
    }

    public void setTreeOrder(int treeOrder) {
        this.treeOrder = treeOrder;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    /**
     * 功能描述：实现集合根据treeOrder字段进行排序的功能
     * @param o
     * @return
     */
    @Override
    public int compareTo(Tree o) {
        long i = this.getTreeOrder() - o.getTreeOrder();
        return Integer.parseInt(i+"");
    }
}
